import 'package:flutter/material.dart';

typedef bool IsShow();

class LoadingWidget extends StatefulWidget {
  final Widget child;

  LoadingWidget({this.child, this.isShow});

  final bool isShow;

  @override
  _LoadingWidgetState createState() => _LoadingWidgetState();
}

class _LoadingWidgetState extends State<LoadingWidget> {
  @override
  Widget build(BuildContext context) {
    return Stack(
      children: <Widget>[
        widget.child,
        Offstage(
          offstage: widget.isShow,
          child: _loadWidget(),
        )
      ],
    );
  }

  Widget _loadWidget() {
    return Center(
      child: Container(
        alignment: Alignment.center,
        color: Colors.grey[200],
        width: 150.0,
        height: 150.0,
        child: Center(
          child: Text("Loading ..."),
        ),
      ),
    );
  }
}
